From cada8e6bbe3b1311853b9f41957c7428004b930a Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 16 Mar 2016 17:45:18 -0700 Subject: [PATCH] Add docs for RUSTFLAGS and build.rustflags --- src/bin/rustc.rs | 4 +++- src/doc/config.md | 11 ++++++----- src/doc/environment-variables.md | 14 ++++++++++---- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/bin/rustc.rs b/src/bin/rustc.rs index fc4b89790..aae58dfb8 100644 --- a/src/bin/rustc.rs +++ b/src/bin/rustc.rs @@ -60,7 +60,9 @@ will simply be added to the compiler invocation. This command requires that only one target is being compiled. If more than one target is available for the current package the filters of --lib, --bin, etc, -must be used to select which target is compiled. +must be used to select which target is compiled. To pass flags to all compiler +processes spawned by Cargo, use the $RUSTFLAGS environment variable or the +`build.rustflags` configuration option. "; pub fn execute(options: Options, config: &Config) -> CliResult> { diff --git a/src/doc/config.md b/src/doc/config.md index 8b8bb5090..133703873 100644 --- a/src/doc/config.md +++ b/src/doc/config.md @@ -79,11 +79,12 @@ proxy = "..." # HTTP proxy to use for HTTP requests (defaults to none) timeout = 60000 # Timeout for each HTTP request, in milliseconds [build] -jobs = 1 # number of jobs to run by default (default to # cpus) -rustc = "rustc" # the rust compiler tool -rustdoc = "rustdoc" # the doc generator tool -target = "triple" # build for the target triple -target-dir = "target" # path of where to place all generated artifacts +jobs = 1 # number of jobs to run by default (default to # cpus) +rustc = "rustc" # the rust compiler tool +rustdoc = "rustdoc" # the doc generator tool +target = "triple" # build for the target triple +target-dir = "target" # path of where to place all generated artifacts +rustflags = ["..", ".."] # custom flags to pass to all compiler invocations [term] verbose = false # whether cargo provides verbose output diff --git a/src/doc/environment-variables.md b/src/doc/environment-variables.md index da9ac2058..8f77b5c91 100644 --- a/src/doc/environment-variables.md +++ b/src/doc/environment-variables.md @@ -6,21 +6,27 @@ with them: # Environment variables Cargo reads -You can override these environment variables to change Cargo's behavior on your system: +You can override these environment variables to change Cargo's behavior on your +system: * `CARGO_HOME` - Cargo maintains a local cache of the registry index and of git checkouts of crates. By default these are stored under `$HOME/.cargo`, but this variable overrides the location of this directory. Once a crate is cached it is not removed by the clean command. -* `CARGO_PROFILE` - If this is set to a positive integer *N*, Cargo will record - timing data as it runs. When it exits, it will print this data as a profile - *N* levels deep. * `CARGO_TARGET_DIR` - Location of where to place all generated artifacts, relative to the current working directory. * `RUSTC` - Instead of running `rustc`, Cargo will execute this specified compiler instead. * `RUSTDOC` - Instead of running `rustdoc`, Cargo will execute this specified `rustdoc` instance instead. +* `RUSTFLAGS` - A space-separated list of custom flags to pass to all compiler + invocations that Cargo performs. In contrast with `cargo rustc`, this is + useful for passing a flag to *all* compiler instances. + +Note that Cargo will also read environment variables for `.cargo/config` +configuration values, as described in [that documentation][config-env] + +[config-env]: config.html#environment-variables # Environment variables Cargo sets for crates -- 2.30.2